home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / RCS / db.h,v < prev    next >
Encoding:
Text File  |  1989-06-23  |  5.8 KB  |  273 lines

  1. head     1.7;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.7
  10. date     89.06.23.11.27.53;  author rab;  state Exp;
  11. branches ;
  12. next     1.6;
  13.  
  14. 1.6
  15. date     89.01.13.09.40.12;  author douglis;  state Exp;
  16. branches ;
  17. next     1.5;
  18.  
  19. 1.5
  20. date     88.11.10.17.23.41;  author douglis;  state Exp;
  21. branches ;
  22. next     1.4;
  23.  
  24. 1.4
  25. date     88.09.21.14.10.16;  author douglis;  state Exp;
  26. branches ;
  27. next     1.3;
  28.  
  29. 1.3
  30. date     88.09.21.14.09.17;  author douglis;  state Exp;
  31. branches ;
  32. next     1.2;
  33.  
  34. 1.2
  35. date     88.09.13.16.51.59;  author douglis;  state Exp;
  36. branches ;
  37. next     1.1;
  38.  
  39. 1.1
  40. date     88.08.12.16.24.07;  author douglis;  state Exp;
  41. branches ;
  42. next     ;
  43.  
  44.  
  45. desc
  46. @Declarations for the generic "database" package.
  47. @
  48.  
  49.  
  50. 1.7
  51. log
  52. @*** empty log message ***
  53. @
  54. text
  55. @/*
  56.  * db.h --
  57.  *
  58.  *    Declarations of constants and structures for the db module.
  59.  *
  60.  * Copyright 1987, 1988 Regents of the University of California
  61.  * Permission to use, copy, modify, and distribute this
  62.  * software and its documentation for any purpose and without
  63.  * fee is hereby granted, provided that the above copyright
  64.  * notice appear in all copies.  The University of California
  65.  * makes no representations about the suitability of this
  66.  * software for any purpose.  It is provided "as is" without
  67.  * express or implied warranty.
  68.  *
  69.  * $Header: /sprite/src/lib/include/RCS/db.h,v 1.6 89/01/13 09:40:12 douglis Exp Locker: rab $ SPRITE (Berkeley) 
  70.  */
  71.  
  72. #ifndef _DB
  73. #define _DB
  74.  
  75. /*
  76.  * A file can be locked for the entire duration it is open (for example,
  77.  * scanning the entire database for records), each time it is written or
  78.  * read (for example, when updating the shared load average file one might
  79.  * want to leave it open but lock it only during updates), or not at all
  80.  * for example, the file specific to a host that is shared between one process
  81.  * updating it and one process reading it, each atomic).
  82.  */
  83. typedef enum {
  84.     DB_LOCK_OPEN,        /* lock the file on open and keep it locked
  85.                  * until close. */
  86.     DB_LOCK_ACCESS,        /* lock should be obtained each time
  87.                  * the file is accessed. */
  88.     DB_LOCK_NEVER,        /* do not lock the file at all */
  89.     DB_LOCK_READ_MOD_WRITE,    /* lock should be obtained when the file
  90.                  * is read and released when it is
  91.                  * written. */
  92. } Db_LockWhen;
  93.  
  94. /*
  95.  * Action to take when obtaining a lock: abort immediately, poll for a
  96.  * timeout period, poll forever, or poll but break the lock upon timeout.
  97.  * DB_LOCK_NONE is equivalent to DB_LOCK_NEVER but is used for the single
  98.  * open + read/write + close interface.
  99.  */
  100. typedef enum {
  101.     DB_LOCK_NO_BLOCK,        /* return immediately with error */
  102.     DB_LOCK_POLL,        /* poll the lock; time out if necessary */
  103.     DB_LOCK_WAIT,        /* wait indefinitely */
  104.     DB_LOCK_BREAK,        /* poll, plus break the lock if needed */
  105.     DB_LOCK_NONE,        /* do not lock the file at all */
  106. } Db_LockHow;
  107.  
  108. /*
  109.  * Information used for repeated scanning through database.
  110.  */
  111.  
  112. typedef struct {
  113.     int          streamID;    /* stream identifier for the open file */
  114.     int          lockType;    /* LOCK_{SH,EX} */
  115.     Db_LockWhen      lockWhen;    /* See above */
  116.     Db_LockHow       lockHow;    /* See above */
  117.     int          structSize;    /* size of one entry */
  118.     int          index;    /* current index into file */
  119.     int          firstRec;      /* index of first record stored in buffer */
  120.     int          numBuf;      /* number of records in buffer */
  121.     char      *buffer;    /* pointer to buffer containing records */
  122.     char      *fileName;    /* name of database file, for error messages */
  123. } Db_Handle;
  124.  
  125. extern int     Db_Open();
  126. extern int     Db_Close();
  127.  
  128. /*
  129.  * The following two routines perform (optional lock)/io/(optional unlock)
  130.  * together.
  131.  */
  132. extern int     Db_Get();
  133. extern int     Db_Put();
  134.  
  135. /*
  136.  * The following two routines perform open/lock/io/unlock/close together.
  137.  */
  138. extern int     Db_WriteEntry();
  139. extern int     Db_ReadEntry();
  140.  
  141. #endif /* _DB */
  142. @
  143.  
  144.  
  145. 1.6
  146. log
  147. @changed Db_Header structure to allow for buffering.
  148. @
  149. text
  150. @d15 1
  151. a15 1
  152.  * $Header: /sprite/src/lib/include/RCS/db.h,v 1.5 88/11/10 17:23:41 douglis Exp Locker: douglis $ SPRITE (Berkeley) 
  153. d87 1
  154. a87 1
  155. #endif _DB
  156. @
  157.  
  158.  
  159. 1.5
  160. log
  161. @added an option to say to lock a database when doing a get and wait for
  162. the subsequent put to unlock it.
  163. @
  164. text
  165. @d15 1
  166. a15 1
  167.  * $Header: /sprite/src/lib/include.new/RCS/db.h,v 1.4 88/09/21 14:10:16 douglis Exp Locker: douglis $ SPRITE (Berkeley) 
  168. a62 1
  169.     int          index;    /* index into file */
  170. d64 5
  171. @
  172.  
  173.  
  174. 1.4
  175. log
  176. @changed old sprite lock name in comment to be LOCK_SH/EX
  177. @
  178. text
  179. @d15 1
  180. a15 1
  181.  * $Header: db.h,v 1.3 88/09/21 14:09:17 douglis Exp $ SPRITE (Berkeley) 
  182. d35 3
  183. @
  184.  
  185.  
  186. 1.3
  187. log
  188. @removed Db_LockDesc, which is now an internal procedure.
  189. @
  190. text
  191. @d15 1
  192. a15 1
  193.  * $Header: db.h,v 1.2 88/09/13 16:51:59 douglis Exp $ SPRITE (Berkeley) 
  194. d57 1
  195. a57 1
  196.     int          lockType;    /* IOC_LOCK_{SHARED,EXCLUSIVE} */
  197. @
  198.  
  199.  
  200. 1.2
  201. log
  202. @Added DB_LOCK_NONE as specification saying not to lock the file at all.
  203. Changed DATABASE to DB and DB to Db.
  204. @
  205. text
  206. @d15 1
  207. a15 1
  208.  * $Header: proto.h,v 1.7 87/01/04 17:28:51 andrew Exp $ SPRITE (Berkeley) 
  209. a78 6
  210.  
  211. /*
  212.  * The following routine may be used to lock the file associated with a
  213.  * Db_Handle.
  214.  */
  215. extern int     Db_LockDesc();
  216. @
  217.  
  218.  
  219. 1.1
  220. log
  221. @Initial revision
  222. @
  223. text
  224. @d2 1
  225. a2 1
  226.  * dataBase.h --
  227. d4 1
  228. a4 1
  229.  *    Declarations of constants and structures for the database module.
  230. d15 1
  231. a15 1
  232.  * $DataBase: proto.h,v 1.7 87/01/04 17:28:51 andrew Exp $ SPRITE (Berkeley) 
  233. d18 2
  234. a19 2
  235. #ifndef _DATABASE
  236. #define _DATABASE
  237. d35 1
  238. a35 1
  239. } DB_LockWhen;
  240. d40 2
  241. d48 2
  242. a49 1
  243. } DB_LockHow;
  244. d58 2
  245. a59 2
  246.     DB_LockWhen      lockWhen;    /* See above */
  247.     DB_LockHow       lockHow;    /* See above */
  248. d62 1
  249. a62 1
  250. } DB_Handle;
  251. d64 2
  252. a65 2
  253. extern int     DB_Open();
  254. extern int     DB_Close();
  255. d71 2
  256. a72 2
  257. extern int     DB_Get();
  258. extern int     DB_Put();
  259. d77 2
  260. a78 2
  261. extern int     DB_WriteEntry();
  262. extern int     DB_ReadEntry();
  263. d82 1
  264. a82 1
  265.  * DB_Handle.
  266. d84 1
  267. a84 1
  268. extern int     DB_LockDesc();
  269. d86 1
  270. a86 1
  271. #endif _DATABASE
  272. @
  273.